<?php
require_once( '../includes/init.php');
 //die('test');
ini_set('display_errors',0);
function checkLogin() 
	{
		require_once ('class_passport.php' );
		$clsPassport = new x_Passport;
		$clsPassport->appId = 10; // 通行证服务ID
		$clsPassport->encryptKey = 'k4kfEOJdi9asUWKKSDXxCKDIfjsoUH5Aa09dnAB'; // 私钥
		/****** 登陆认证 ******/
		// 第一步：
		//$clsPassport->verify ();

		// 第二步，保存 Passport 信息到当前程序的 Session
		$userSession = $clsPassport->vars;
		/*
		这里为保孿Session 代码
		*/
		if ( $clsPassport->vars['app_user_id'] > 0 )
		{
			// 若账号已激活表示已登陆当前程序
		}
		// 注：无需每次都验诿Passport，可以先通过用户在当前程序本身的 Session 判断是否已登陿
        //print_r($userSession);die();

		/****** 获取程序列表 ******/
		// $appType : 程序的类垿系统程序丿, 游戏丿
		//$appList = $clsPassport->appGetList ( $appType );
		$_SESSION['union_username'] = $userSession["username"];
		$_SESSION['union_nickname'] = $userSession["nickname"];
		return $_SESSION['union_username'];
	}
if ($_SESSION['union_username'] =='') {  
    checkLogin();
} 

$siteObj=alps::newClass('mod_site','mod');

$_SERVER['HTTP_HOST'] = 'kenny.9wee.com';
$siteInfo = $siteObj->getSiteInfo($_SERVER['HTTP_HOST']);                                                     $cookie=$siteInfo['apply_id'].'_'.'100'.'_'.$siteInfo['site_id'];
$smarty->assign('cookies',$cookie);

if (empty($siteInfo)) die('请检查域名是否错误');

$siteInfo['footer_code']=htmlspecialchars_decode($siteInfo['footer_code']);

require_once('include.php');

$smarty->assign('siteInfo',$siteInfo);
if ($siteInfo['site_status']==3) {
echo "<script>alert('网站审核没有通过');window.close();</script>";die;
}
if ($siteInfo['site_status']==1) {
echo "<script>alert('您的网站正在审核');window.close();</script>";die;
}
$tplInfo = $siteObj->getTpl($siteInfo['template_id']);                                                         //得到模板
$tplpath=$tplInfo['temppath'];

$countInfo_arr=explode(':',$siteInfo['count']);                                                                //站长统计
$countType=$countInfo_arr[0];
$smarty->assign('countType',$countType);
$countParam=explode('|',$countInfo_arr[1]);
$smarty->assign('countParam',$countParam);

$smarty->cache_lifetime = 3600;
//$smarty->caching = true;

//function smarty_block_cacheless($param, $content, &$smarty) {                                                  //定义block插件
//return $content;
//}
//$smarty->register_block('cacheless', 'smarty_block_cacheless', false);

$smarty->use_sub_dirs = true;
$my_cache_id=md5($_SERVER['HTTP_HOST']);
if(!$smarty->is_cached($tplpath.'index.html',$my_cache_id)) {

	$hdzx = $siteObj->getnewslist(7,'',10);                                                                          //活动中心
	$smarty->assign('hdzx_last',$hdzx);

	$hdzx_last=$siteObj->getactivlist(100, 2);
	$smarty->assign('image_domain',IMAGE_DOMAIN);
	$smarty->assign('hdzx_new',$hdzx_last);

	$xwgg = $siteObj->getnewslist(5,'',10);                                                                          // 新闻公告
	$smarty->assign('xwgg',$xwgg);

	$yjzx = $siteObj->getnewslist(3,'',10);                                                                          //业界资讯
	$smarty->assign('yjzx',$yjzx);
}
$smarty->assign('backaddress',$_SERVER['HTTP_HOST']);

$cachepath1=substr($my_cache_id,0,2);
$cachepath2=substr($my_cache_id,2,2);
$smarty->display($tplpath.'index.html',$cachepath1.'|'.$cachepath2.'|'.$my_cache_id); 
?>